import {get} from 'lodash'
import Cookie from 'js-cookie'
import request from '../api/request'
import store from "../store";


export const geterrormessage = error => {
  //目标对象 获取路径 默认值
  return get(error, 'response.data.errormessage', error.message)
}

export const myconsole = (str) => {
  console.log(str)
  console.log(str)
  console.log(str)
  console.log(str)
  console.log(str)
  console.log(str)
  console.log(str)
}

export const mymixin = {
  created: function () {
    this.hello()
  },
  data: function () {
    return {
      message: '123',
      bar: '123'
    }
  },
  methods: {
    hello: function () {
      console.log('hello from mixin!')
    }
  }
}

// export const Cookies2 = Cookie.noConflict();


export const cookieSetting = function () {
  Object.assign(Cookie.defaults, {expires: 7})
}

export const doAuth = function () {
  let token = Cookie.get('token')
  return token && token.length > 0
}

export const testRequest = function () {
  // const myInterceptors = request.interceptors.request.use(config => {
  //   console.error('i am testRequest')
  //   return config
  // })
  // console.log(myInterceptors)
  // return myInterceptors
  const abc=request.interceptors.request.use(config => {
    console.error('i am testRequest')
    return config
  })
  request.interceptors.request.eject(abc);
}

// const myInterceptors = request.interceptors.request.use(config => {
//   console.error('i am testRequest')
//   return config
// })
